/**
 * 活动模块item
 */
import React, {Component} from 'react';
import {View, StyleSheet, Text, TouchableOpacity, Image} from  'react-native';
let dimension = require('Dimensions');
let {width, height} = dimension.get('window');
export default class ActivityItem extends Component {
    render() {
        return (
            <TouchableOpacity onPress={()=>this.clickCell("https://h5.youzan.com/v2/showcase/feature?alias=1hchin34r&reft=1495684861145_1495684870550&spm=f44838959_f44930604&sf=wx_menu","活动")}>
                <View style={styles.container}>
                    <View>
                        <Text style={[styles.textStyle,{color:this.props.titleColor}]}>{this.props.title}</Text>
                        <Text style={styles.subTitleStyle}>{this.props.subTitle}</Text>
                    </View>
                    <Image source={this.props.image} style={{width:64,height:43}}/>
                </View>
            </TouchableOpacity>
        )
    }

    clickCell(url,title) {
        // 判断处理
        if (this.props.callBackClickCell == null) return;
        // 执行回调函数
        this.props.callBackClickCell(url,title);
    }
}
ActivityItem.propTypes = {
    title: React.PropTypes.string,
    subTitle: React.PropTypes.string,
    image: React.PropTypes.number,
    titleColor: React.PropTypes.string,
    callBackClickCell: React.PropTypes.func,
    tplurl: React.PropTypes.string
};
ActivityItem.defaultProps = {
    title: '',
    subTitle: '',
    image: null,
    titleColor: '',
    callBackClickCell: null,
    tplurl: ''
};
const styles = StyleSheet.create({
    container: {
        backgroundColor: 'white',
        width: (width -1)*0.5,
        height: 59,
        flexDirection: 'row',
        marginBottom: 1,
        alignItems: 'center',
        justifyContent: 'space-around',
        // marginRight: 1
    },
    textStyle: {
        fontSize: 18,
        fontWeight: 'bold'
    },
    subTitleStyle: {
        color: 'gray'
    }
});
